package main

import "fmt"

func changeValue(m map[string]string) {
	m["name"] = "jack"
}
func goMap() {
	// []中为key
	var myMap map[string]string
	myMap = make(map[string]string, 10)
	myMap["name"] = "tom"
	myMap["age"] = "18"
	fmt.Println(myMap["name"])
	fmt.Println(myMap)
	// 声明方式二
	myMap2 := map[string]string{
		"name": "tom",
		"age":  "18",
	}
	fmt.Println(myMap2)

	//遍历
	for k, v := range myMap {
		fmt.Println(k, ":", v)
	}

	//删除
	delete(myMap, "name")
	fmt.Println(myMap)

	//map函数传参为引用类型
	changeValue(myMap)
	fmt.Println(myMap)
}
